package com.jeecms.edu.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.jeecms.common.web.ResponseUtils;
import com.jeecms.edu.entity.SchoolInformation;

/**
 * 跳转list页，幼儿园、小学、初中、高中
 */
@WebServlet("/ShowSchoolTypeAll")
public class ShowSchoolTypeAll extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		PrintWriter writer=response.getWriter();
		String result="";
		String schooltype=request.getParameter("schooltype");
		String schoollevel=schooltype;
		switch (schooltype) {
		case "幼儿园":
			schooltype="('幼儿园')";
			break;
		case "小学":
			schooltype="('9年制学校','12年制学校','小学')";
			break;
		case "初中":
			schooltype="('9年制学校','4年制初级中学','12年制学校','7年制完全中学')";
			break;
		case "高中":
			schooltype="('12年制学校','3年制高级中学','7年制完全中学')";
			break;
		}
		List list=SchoolInformation.checkSchoolTypeAll(schooltype);
		JSONObject jsonObject=new JSONObject();
		if (null!=list && list.size()!=0) {
			request.getSession().getServletContext().setAttribute("schoollist", list);
			request.getSession().getServletContext().setAttribute("exadd", schoollevel);
			jsonObject.put("report", "0");
			String json = jsonObject.toJSONString();
			ResponseUtils.renderJson(response, json); 
		}else{
			jsonObject.put("report", "1");
			String json = jsonObject.toJSONString();
			ResponseUtils.renderJson(response, json);
		}
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
}
